package com.cc.service.impl;

import com.cc.mapper.EmpMapper;
import com.cc.mapper.StudentMapper;
import com.cc.pojo.ClassOption;
import com.cc.pojo.JobCountData;
import com.cc.pojo.JobOption;
import com.cc.pojo.StudentCountDate;
import com.cc.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    private EmpMapper empMapper;
    @Autowired
    private StudentMapper studentMapper;
    @Override
    public JobOption getEmpJobData() {
        JobOption jobOption = new JobOption();
        List<JobCountData> jobCountDataList = empMapper.countEmpJobData();
        //设置jobList, JobCountData转成字符串
        List<String> jobList = jobCountDataList.stream().map(JobCountData::getJobName).toList();
        jobOption.setJobList(jobList);

        //设置dataList
        List<Integer> dataList = jobCountDataList.stream().map(JobCountData::getNum).toList();
        jobOption.setDataList(dataList);

        return jobOption;

    }

    @Override
    public List<Map> getEmpGenderData() {

        return empMapper.getEmpGenderData();
    }

    @Override
    public List<Map> getStudentDegreeData() {
        return studentMapper.getStudentDegreeData();
    }



    @Override
    public ClassOption getStudentCountData() {
        ClassOption classOption = new ClassOption();
        List<StudentCountDate> classCountData = studentMapper.getStudentCountData();

        List<String> classList = classCountData.stream().map(StudentCountDate::getClassName).toList();
        classOption.setClazzList(classList);

        List<Integer> dataList = classCountData.stream().map(StudentCountDate::getNum).toList();
        classOption.setDataList(dataList);
        return classOption;


    }
}
